package com.zhangsun.springRabbitMq.producer;

import com.zhangsun.springRabbitMq.bean.User;
import com.zhangsun.springRabbitMq.common.RabbitMqDirectConstant;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Direct模式生产者
 */
@Component
public class HelloProducer {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    /**
     * 发送消息
     *
     * @param user 参数
     */
    public void send(User user) {
        rabbitTemplate.convertAndSend(RabbitMqDirectConstant.QUEUE_HELLO, user);
    }

}
